from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        DROP INDEX IF EXISTS "idx_device_mode_name_a93a32";
        DROP INDEX IF EXISTS "idx_device_grou_name_47c2d0";
        DROP INDEX IF EXISTS "idx_device_serial__b98e5e";
        DROP INDEX IF EXISTS "idx_device_name_d43932";
        CREATE UNIQUE INDEX IF NOT EXISTS "uid_device_name_d43932" ON "device" ("name");
        CREATE UNIQUE INDEX IF NOT EXISTS "uid_device_serial__b98e5e" ON "device" ("serial_number");
        CREATE UNIQUE INDEX IF NOT EXISTS "uid_device_grou_name_47c2d0" ON "device_groups" ("name");
        CREATE UNIQUE INDEX IF NOT EXISTS "uid_device_mode_name_a93a32" ON "device_models" ("name");
        CREATE UNIQUE INDEX IF NOT EXISTS "uid_monitor_met_metric__075449" ON "monitor_metrics" ("metric_name");"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        DROP INDEX IF EXISTS "uid_monitor_met_metric__075449";
        DROP INDEX IF EXISTS "uid_device_mode_name_a93a32";
        DROP INDEX IF EXISTS "uid_device_grou_name_47c2d0";
        DROP INDEX IF EXISTS "uid_device_serial__b98e5e";
        DROP INDEX IF EXISTS "uid_device_name_d43932";
        CREATE INDEX IF NOT EXISTS "idx_device_name_d43932" ON "device" ("name");
        CREATE INDEX IF NOT EXISTS "idx_device_serial__b98e5e" ON "device" ("serial_number");
        CREATE INDEX IF NOT EXISTS "idx_device_grou_name_47c2d0" ON "device_groups" ("name");
        CREATE INDEX IF NOT EXISTS "idx_device_mode_name_a93a32" ON "device_models" ("name");"""
